<!-- 工作票统计记录 entity.jsp -->
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<html>
	<head>
		<script type="text/javascript" src="<%=contextPath%>/js/jquery-1.3.2.min.js"></script> 
		<script type="text/javascript" src="<%=contextPath%>/js/validator.js"></script> 
		<script type="text/javascript" src="<%=contextPath%>/js/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" language="javascript">  
			
			Ext.onReady(function(){
				var tb = new Ext.Toolbar({
			   		renderTo: document.all.tbar,
			    	items: [
				        {
				            text: '保存',
				            icon:"<%=contextPath%>/images/save.gif",
				            handler:toCheck,
				            hidden:<%=session.getAttribute("btn_savegzpjl_display") != null 
				            || "1".equals(session.getAttribute("SESSION_ISADMIN")) 
				            || session.getAttribute("btn_confirmgzrwd_display") != null ? false:true%>
				        },'-',
				        {
				            text: '返回',
				            icon:"<%=contextPath%>/images/fanhui.png",
				            handler:function(){
				            
				            	if ('${searchBean.con19}' == 'search') {
										document.frmM.action = "<%=contextPath%>/zbjlSearchList!getList.do";
     									document.frmM.submit();
				            	} else if ('${searchBean.con19}' == 'gzrwd') {
				            	
				            		window.close();
				            	} else {
				            		<c:if test="${comefrom != 'yg'}">
				            			back();
				            		</c:if>
				            		<c:if test="${comefrom == 'yg'}">
				            			parent.deleteTab("detail_tabPanel" + document.getElementById("entity.id").value);
				            		</c:if>
				            	
				            	} 
				            }
				        }
			    	]
			    });
			});
		
			function toCheck(){

			  	if(!Validator.Validate(frmM,2)){
				  return false;
			  	}

  				comt();
  		
		    } 
		    
		 </script>  
	</head>
	<body >
		
	<div id = "tbar" style="position:absolute;display:block left:0px; top:0px; width:100%; height:35px; z-index:1;"></div>
	<br>
	<div id="Layer" style="position:absolute;display:block left:0px; top:35px; width:100%; height:94%; z-index:1000; overflow:auto;">
		
		<!-- 信息提示 -->
		<div id="result" align="center"><font color="red">${info }</font></div>
		<table width="100%" height="30" >
			<tr>
				<td colspan="4" align="center">
					工作票统计记录
				</td>
			</tr>
		</table>
		<form id="frmM" name="frmM" method="POST" action="<%=contextPath%>/user!save.do">
		<input type="hidden" name="searchBean.con15" value="${entity.id}"/>
			<s:hidden name="entity.id"/>
			<s:hidden name="entity.bdz"/>
			<s:hidden name="entity.ouid"/>
			<s:hidden name="entity.state"/>
			<s:hidden name="entity.gzygid"/>
			<s:hidden name ="entity.fzrdw"/>
			<s:hidden name ="entity.gzfzr"/>
			<s:hidden name ="entity.gzfzrbd"/>
			<s:hidden name="comefrom"/>

			<table width="100%" id="infotab">
				<tr>
					<th width="120" >
						<font color="red">*</font>&nbsp;变电站：
					</th>
					<td nowrap>
						<input type="text" readonly="true" datatype="Require" style="width:50%" name="entity.bdzname" value="${entity.bdzname}" msg="变电站必须输入。" size="25"/>
						
					</td>
					<th width="120" >
						<font color="red"></font>&nbsp;票号：
					</th>
					<td nowrap>
						<input type="text"  readonly="true" style="width:50%" name="entity.ph" value="${entity.ph}" maxlength="25" msg="票号必须输入。"/>
					</td>
				</tr>
				<tr>
					<th width="120" nowrap>
						<font color="red">*</font>&nbsp;类  型：
					</th>
					<td>
						<s:select emptyOption="true" datatype="Require" list="gzptzlxList" name="entity.lx" width="300" listKey="itemId" listValue="itemName" msg="类 型必须输入。"/>
					</td>
					
				</tr>
				
				<tr>
					<th width="120" nowrap>
						<font color="red">*</font>&nbsp;工作任务：
					</th>
					<td colspan="3">
						<textarea  style="width:90%" datatype="LimitB" min="1"  max="500" rows="3" name="entity.gzrw" msg="工作任务必须输入并且最多输入250个汉字。">${entity.gzrw}</textarea>
					</td>
				</tr>
				
				<tr>
					<th width="120" nowrap>
						<font color="red"></font>&nbsp;计划工作开始时间：
					</th>
					<td>
						<input type="text" datatype="Require"  datatype="Require" name="entity.jhgzsjks" readonly="true" value='<fmt:formatDate value="${entity.jhgzsjks}" pattern="yyyy-MM-dd HH:mm"/>' msg="计划工作开始时间必须输入。"/>
						
					</td>
					<th width="120" nowrap>
						<font color="red"></font>&nbsp;计划工作结束时间：
					</th>
					<td>
						<input type="text" datatype="Require"  datatype="Require" name="entity.jhgzsjjs" readonly="true" value='<fmt:formatDate value="${entity.jhgzsjjs}" pattern="yyyy-MM-dd HH:mm"/>' msg="计划工作结束时间必须输入。"/>
						
					</td>
				</tr>
				<tr>
				<th width="120" nowrap>
						<font color="red">*</font>&nbsp;负责人：
					</th>
					<td >
					    <input type="text"  datatype="Require" readonly="true" style="width:80" name="entity.gzfzrname" value="${entity.gzfzrname}" msg="负责人必须输入。">
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUserselect('entity.gzfzr','entity.gzfzrname')" />
				
					</td>
					
					<th width="120" nowrap>
						<font color="red">*</font>工作班成员:
					</th>
					<td >
						<input type="text"  datatype="Require" readonly="true" style="width:90%" name="entity.gzfzrbdname" value="${entity.gzfzrbdname}" msg="成员必须输入。">
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.gzfzrbd','entity.gzfzrbdname')" />
					</td>
					</tr>
				<tr>
					<th width="120" nowrap>
						收到工作票时间：
					</th>
					<td>
						<input type="text" name="entity.sdgzpsj" readonly="true" value='<fmt:formatDate value="${entity.sdgzpsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="收到工作票时间必须输入。"/>
						
					</td>
					<th width="120" nowrap>
						许可工作时间：
					</th>
					<td>
						<input type="text" onclick="WdatePicker({el:$dp.$('entity.xkgzsj')})" name="entity.xkgzsj" readonly="true" value='<fmt:formatDate value="${entity.xkgzsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="许可工作时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.xkgzsj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
				</tr>
				
				<tr>
					<th width="120" nowrap>
						工作终结时间：
					</th>
					<td>
						<input type="text" name="entity.gzzjsj" onclick="WdatePicker({el:$dp.$('entity.gzzjsj')})" readonly="true" value='<fmt:formatDate value="${entity.gzzjsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="工作终结时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.gzzjsj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
					<th width="120" nowrap>
						工作票终结时间：
					</th>
					<td>
						<input type="text" onclick="WdatePicker({el:$dp.$('entity.gzpzjsj')})" name="entity.gzpzjsj" readonly="true" value='<fmt:formatDate value="${entity.gzpzjsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="工作票终结时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.gzpzjsj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
				</tr>
				
				<tr>
					
					<th width="120" nowrap>
						工作负责人变动时间：
					</th>
					<td>
						<input type="text" onclick="WdatePicker({el:$dp.$('entity.gzfzrbdsj')})" name="entity.gzfzrbdsj" readonly="true" value='<fmt:formatDate value="${entity.gzfzrbdsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="工作负责人变动时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.gzfzrbdsj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
				
					<th width="120" nowrap>
						工作票延期时间：
					</th>
					<td>
						<input type="text" name="entity.gzpyqsj"  onclick="WdatePicker({el:$dp.$('entity.gzpyqsj')})" readonly="true" value='<fmt:formatDate value="${entity.gzpyqsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="工作票延期时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.gzpyqsj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
				</tr>
				<tr>
					<th width="120" nowrap>
						工作票延期原因：
					</th>
					<td colspan="3">
						<input type="text" style="width:90%" name="entity.gzpyqyy" value="${entity.gzpyqyy}" msg="工作票延期原因必须输入。" maxlength="250"/>
					</td>
				</tr>
				
				<tr>
					<th width="120" nowrap>
						存在问题：
					</th>
					<td colspan="3">
						<input type="text" style="width:90%" name="entity.czwt" value="${entity.czwt}" maxlength="250">
					</td>
				</tr>
				
				
			</table>
			
		</form>
		
		</div>
	</body>
</html>
<script language="javascript">

	 // 保存
     function comt(){
     	document.frmM.action = "<%=contextPath%>/gzptjjl!save.do";
     	document.frmM.submit();
     }
     
     // 返回
     function back() {
     	document.frmM.action = "<%=contextPath%>/gzptjjlList!getList.do";
		document.frmM.submit();
     }

	 // 查询
	 function cmt(){
		document.frmM.action = "<%=contextPath%>/gzptjjlList!getList.do?page=1";
		document.frmM.submit();
	 }
	 
	 // 当日开工
	 function drkg () {
	 
	 	if (document.getElementById("entity.cjr").value == "") {
	 		alert("请先保存工作票");
	 		return;
	 	}
	 	var win = window.open("<%=contextPath%>/gzptjjl!initDrkgzj.do?kgFlag=1&id=" + document.getElementById("entity.id").value,"Result_window","left=250,top=30,width=400,height=300,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=yes",true);
	 //	var url = "<%=contextPath%>/gzptjjl!initDrkgzj.do?kgFlag=1&id=" + document.getElementById("entity.id").value;
     //   var win = openSUB(url,2,400,200,450,30);
	 } 
	 
	 // 当日终结
	 function drzj () {
	 
	 	if (document.getElementById("entity.cjr").value == "") {
	 		alert("请先保存工作票");
	 		return;
	 	}
	 	var win = window.open("<%=contextPath%>/gzptjjl!initDrkgzj.do?kgFlag=2&id=" + document.getElementById("entity.id").value,"Result_window","left=250,top=30,width=400,height=300,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=yes",true);    
	 	//var url = "<%=contextPath%>/gzptjjl!initDrkgzj.do?kgFlag=2&id=" + document.getElementById("entity.id").value;
        //var win = openSUB(url,2,400,200,450,30);
	 } 
	 
	 // 当日终结
	 function deleteDrkgzj () {
	 
	 	if (document.getElementById("entity.cjr").value == "") {
	 		alert("没有当日工作开工、终结记录");
	 		return;
	 	}
	 	
		if(confirm("确定要删除当日工作开工、收工记录吗？")) {
		
			Ext.Ajax.request({
					method :'POST',
					url : "<%=contextPath%>/gzptjjl!deleteDrkgzj.do?id=" + document.getElementById("entity.id").value,
					success : function(response) {
        				
        				var obj = Ext.decode(response.responseText);
 
						if (obj["m"] != undefined) {
							alert("删除成功");
        				} else {
        					alert("删除失败");
        				}
						

					},
					failure : function() {
						alert("异步失败！");
							return false;
					}
			});
		
		}

	 } 
	  
	 // 工作票提前办理终结
	 function gzptqzj () {
	 
	 	if (document.getElementById("entity.cjr").value == "") {
	 		alert("请先保存工作票");
	 		return;
	 	}
	 	
		if(confirm("确定要提前办理该工作票终结吗？")) {
		
			Ext.Ajax.request({
					method :'POST',
					url : "<%=contextPath%>/gzptjjl!gzptqzj.do?id=" + document.getElementById("entity.id").value,
					success : function(response) {
        				
        				var obj = Ext.decode(response.responseText);
 
						if (obj["m"] != undefined) {
							alert("提前办理终结成功");
        				} else {
        					alert("提前办理终结失败");
        				}
						

					},
					failure : function() {
						alert("异步失败！");
							return false;
					}
			});
		
		}

	 } 
	 // 取消工作票记录
     function cancelGzptjjl(btn, text) {
     
     	if (btn == "ok") {
     	
     		if (text == "" || text.length > 25) {
     			Ext.MessageBox.alert('提示','取消通知人必须输入');
     			Ext.MessageBox.prompt('取消工作票记录','取消通知人', cancelGzptjjl);
     			return;
     		}
     	
     		var ygid = document.getElementById("entity.id").value;
     	
			// 判断这个任务是否已经生成了任务
			Ext.Ajax.request({
					method :'POST',
					url : "<%=contextPath%>/gzptjjl!cancelGzptjjl.do?qxtzr=" + text,
					params:{id:ygid},
					success : function(response) {
        				back();
        				Ext.MessageBox.alert('提示','取消成功');
						
					},
					failure : function() {
						Ext.MessageBox.alert('提示','取消失败');
						return false;
					}
		});
     	
     	}
     	}
</script>